package top.cluski.feieprint.domain.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class FeiEPrintErrorContext {
    MainError mainError;
    SubError subError;

    String printerName;

    public enum MainError {
        PRINT_ERROR,
        PARAM_ERROR,
    }

    public enum SubError {
        SEND_FAIL,
        PRINTER_NOT_FOUND,
        UNKNOWN_ERROR
    }

    public String getMainErrorMessage() {
        switch (this.mainError) {
            case PRINT_ERROR -> {
                return "打印错误";
            }
            case PARAM_ERROR -> {
                return "参数错误";
            }
            default -> throw new IllegalArgumentException("未知的主错误类型");
        }
    }

    public String getSubErrorMessage() {
        switch (this.subError) {
            case SEND_FAIL -> {
                return "发送失败";
            }
            case PRINTER_NOT_FOUND -> {
                return "打印机未找到";
            }
            case UNKNOWN_ERROR -> {
                return "未知错误";
            }
            default -> throw new IllegalArgumentException("未知的子错误类型");
        }
    }
}
